<?php
/**
 * footer code - calculates information for display, and calls the template file for footer-rendering
 *
 * @package templateStructure
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: footer.php 3428 2006-04-13 05:03:41Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
$time_start = explode(' ', PAGE_PARSE_START_TIME);
$time_end = explode(' ', microtime());
$parse_time = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);

if (STORE_PAGE_PARSE_TIME == 'true') {
  error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' - ' . $_SERVER['REQUEST_URI'] . ' (' . $parse_time . 's)' . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
}

  unset($information_footer);

  if (DEFINE_SHIPPINGINFO_STATUS <= 1) {
    $information_footer[] = '<a href="' . zen_href_link(FILENAME_SHIPPING) . '">' . BOX_INFORMATION_SHIPPING . '</a>';
  }
  if (DEFINE_PRIVACY_STATUS <= 1) {
    $information_footer[] = '<a href="' . zen_href_link(FILENAME_PRIVACY) . '">' . BOX_INFORMATION_PRIVACY . '</a>';
  }
  if (DEFINE_CONDITIONS_STATUS <= 1) {
    $information_footer[] = '<a href="' . zen_href_link(FILENAME_CONDITIONS) . '">' . BOX_INFORMATION_CONDITIONS . '</a>';
  }
  if (DEFINE_CONTACT_US_STATUS <= 1) {
    $information_footer[] = '<a href="' . zen_href_link(FILENAME_CONTACT_US) . '">' . BOX_INFORMATION_CONTACT . '</a>';
  }

// Forum (phpBB) link:
  if ( (isset($phpBB->phpBB['db_installed_config']) && $phpBB->phpBB['db_installed_config']) && (isset($phpBB->phpBB['files_installed']) && $phpBB->phpBB['files_installed'])  && (PHPBB_LINKS_ENABLED=='true')) {
    $information_footer[] = '<a href="' . zen_href_link($phpBB->phpBB['phpbb_url'] . FILENAME_BB_INDEX, '', 'NONSSL', false, '', true) . '" target="_blank">' . BOX_BBINDEX . '</a>';
// or: $phpBB->phpBB['phpbb_url'] . FILENAME_BB_INDEX
// or: str_replace(str_replace(DIR_WS_CATALOG, '', DIR_FS_CATALOG), '', DIR_WS_PHPBB)
  }

  if (DEFINE_SITE_MAP_STATUS <= 1) {
    $information_footer[] = '<a href="' . zen_href_link(FILENAME_SITE_MAP) . '">' . BOX_INFORMATION_SITE_MAP . '</a>';
  }

  // only show GV FAQ when installed
  if (MODULE_ORDER_TOTAL_GV_STATUS == 'true') {
    $information_footer[] = '<a href="' . zen_href_link(FILENAME_GV_FAQ) . '">' . BOX_INFORMATION_GV . '</a>';
  }
  // only show Discount Coupon FAQ when installed
  if (DEFINE_DISCOUNT_COUPON_STATUS <= 1 && MODULE_ORDER_TOTAL_COUPON_STATUS == 'true') {
    $information_footer[] = '<a href="' . zen_href_link(FILENAME_DISCOUNT_COUPON) . '">' . BOX_INFORMATION_DISCOUNT_COUPONS . '</a>';
  }

  if (SHOW_NEWSLETTER_UNSUBSCRIBE_LINK == 'true') {
    $information_footer[] = '<a href="' . zen_href_link(FILENAME_UNSUBSCRIBE) . '">' . BOX_INFORMATION_UNSUBSCRIBE . '</a>';
  }

if(defined('REVELATION_FOOTER_PRODUCTS')){
	switch(REVELATION_FOOTER_PRODUCTS){
	case 'special':
	$products_query = "select p.products_id, p.products_image, pd.products_name, p.master_categories_id, p.products_qty_box_status, p.product_is_call, p.products_quantity  
	                           from (" . TABLE_PRODUCTS . " p
	                           left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id
	                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
	                           where p.products_id = s.products_id
	                           and p.products_id = pd.products_id
	                           and p.products_status = '1' and s.status = 1
	                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
	                           ORDER BY RAND() LIMIT 0,10";
	$footer_heading = TEXT_FOOTER_SPECIAL;                      
	break;	
	
	case 'featured':
	$products_query = "select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id, p.products_qty_box_status, p.product_is_call, p.products_quantity  
                           from (" . TABLE_PRODUCTS . " p
                           left join " . TABLE_FEATURED . " f on p.products_id = f.products_id
                           left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
                           where p.products_id = f.products_id
                           and p.products_id = pd.products_id
                           and p.products_status = 1 and f.status = 1
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                           ORDER BY RAND() LIMIT 0,10";
    $footer_heading = TEXT_FOOTER_FEATURED; 
	break;	
	
	case 'latest':
  	$products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                           p.products_date_added, p.products_price, p.products_type, p.master_categories_id, p.products_qty_box_status, p.product_is_call, p.products_quantity
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                           where p.products_id = pd.products_id
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                           and   p.products_status = 1 ORDER BY p.products_date_added LIMIT 0,10";;
    $footer_heading = TEXT_FOOTER_LATEST;                        
	break;					   
	}
}else{
  	$products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                           p.products_date_added, p.products_price, p.products_type, p.master_categories_id, p.products_qty_box_status, p.product_is_call, p.products_quantity
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                           where p.products_id = pd.products_id
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                           and   p.products_status = 1 ORDER BY p.products_date_added LIMIT 0,10";;
    $footer_heading = TEXT_FOOTER_LATEST;                           	
}						   
$products = $db->Execute($products_query);
?>